package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInInvoiceFolder;
import com.ims.core.doc.service.ITInInvoiceFolderService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 进项票夹Controller
 *
 * @author IMS
 * @date 2024-11-10
 */
@RestController
@RequestMapping("/doc/folder")
public class TInInvoiceFolderController extends BaseController
{
    @Autowired
    private ITInInvoiceFolderService tInInvoiceFolderService;

    /**
     * 查询进项票夹列表
     */
    @PreAuthorize("@ss.hasPermi('doc:folder:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInInvoiceFolder tInInvoiceFolder)
    {
        startPage();
        List<TInInvoiceFolder> list = tInInvoiceFolderService.selectTInInvoiceFolderList(tInInvoiceFolder);
        return getDataTable(list);
    }

    /**
     * 导出进项票夹列表
     */
    @PreAuthorize("@ss.hasPermi('doc:folder:export')")
    @Log(title = "进项票夹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInInvoiceFolder tInInvoiceFolder)
    {
        List<TInInvoiceFolder> list = tInInvoiceFolderService.selectTInInvoiceFolderList(tInInvoiceFolder);
        ExcelUtil<TInInvoiceFolder> util = new ExcelUtil<TInInvoiceFolder>(TInInvoiceFolder.class);
        util.exportExcel(response, list, "进项票夹数据");
    }

    /**
     * 获取进项票夹详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:folder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInInvoiceFolderService.selectTInInvoiceFolderById(id));
    }

    /**
     * 新增进项票夹
     */
    @PreAuthorize("@ss.hasPermi('doc:folder:add')")
    @Log(title = "进项票夹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInInvoiceFolder tInInvoiceFolder)
    {
        return toAjax(tInInvoiceFolderService.insertTInInvoiceFolder(tInInvoiceFolder));
    }

    /**
     * 修改进项票夹
     */
    @PreAuthorize("@ss.hasPermi('doc:folder:edit')")
    @Log(title = "进项票夹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInInvoiceFolder tInInvoiceFolder)
    {
        return toAjax(tInInvoiceFolderService.updateTInInvoiceFolder(tInInvoiceFolder));
    }

    /**
     * 删除进项票夹
     */
    @PreAuthorize("@ss.hasPermi('doc:folder:remove')")
    @Log(title = "进项票夹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(tInInvoiceFolderService.deleteTInInvoiceFolderById(id));
    }
}
